import {createRouter, createWebHashHistory} from 'vue-router'
import Layout from "@/layout/index.vue";

/**
 * isHideSidebar 是否不显示侧边栏
 * title 路由名称
 */
// 动态加载路由页
export const asyncRoutes = [

    {
        path: '/',
        component: Layout,
        redirect: '/index',
        meta: {
            title: '首页',
        },
        children: [
            {
                path: 'index',
                name: 'Index',
                meta: {
                    title: '首页',
                    icon: 'HomeOutlined',
                },
                component: () => import('@/views/home/index'),
            },
            {
                path: '/paramsConfig',
                name: 'ParamsConfig',
                meta: {
                    title: '参数配置',
                },
                component: () => import('@/views/paramsConfig/index'),
            },
            {
                path: '/feedback',
                name: 'Feedback',
                meta: {
                    title: '用户反馈',
                },
                component: () => import('@/views/feedback/index'),
            },
            {
                path: '/authority',
                component: Layout,
                name: 'Authority',
                meta: {
                    title: '权限管理',
                    icon: 'SettingOutlined'
                },
                children: [
                    {
                        path: 'menuManage',
                        name: 'MenuManage',
                        meta: {
                            title: '菜单管理',
                        },
                        component: () => import('@/views/authority/menuManage/index'),
                    },
                    {
                        path: 'roleManage',
                        name: 'RoleManage',
                        meta: {
                            title: '角色管理',
                        },
                        component: () => import('@/views/authority/roleManage/index'),
                    },
                    {
                        path: 'userManage',
                        name: 'UserManage',
                        meta: {
                            title: '员工管理',
                        },
                        component: () => import('@/views/authority/userManage/index'),
                    },
                ],
            },
            {
                path: '/order',
                component: Layout,
                name: 'Order',
                meta: {
                    title: '订单管理',
                    icon: 'TransactionOutlined'
                },
                children: [
                    {
                        path: 'orderAllList',
                        name: 'OrderAllList',
                        meta: {
                            title: '全部列表',
                        },
                        component: () => import('@/views/order/orderAllList/index.vue'),
                    },
                    {
                        path: 'orderAgency',
                        name: 'OrderAgency',
                        meta: {
                            title: '待办列表',
                        },
                        component: () => import('@/views/order/orderAgency/index'),
                    },
                    {
                        path: 'orderAgencyKeynote',
                        name: 'OrderAgencyKeynote',
                        meta: {
                            title: '重点待办',
                        },
                        component: () => import('@/views/order/orderAgencyKeynote/index'),
                    },
                    {
                        path: 'orderDetails',
                        name: 'OrderDetails',
                        meta: {
                            title: '订单详情',
                        },
                        component: () => import('@/views/order/orderDetails/index'),
                    },
                ],
            },
            {
                path: '/financial',
                component: Layout,
                name: 'Financial',
                meta: {
                    title: '财务管理',
                    icon: 'SettingOutlined'
                },
                children: [
                    {
                        path: 'expensesDetails',
                        name: 'ExpensesDetails',
                        meta: {
                            title: '收支明细表',
                        },
                        component: () => import('@/views/financial/expensesDetails/index'),
                    },
                    {
                        path: 'netProfit',
                        name: 'NetProfit',
                        meta: {
                            title: '纯利润列表',
                        },
                        component: () => import('@/views/financial/netProfit/index'),
                    },
                    {
                        path: 'consumptionRecords',
                        name: 'ConsumptionRecords',
                        meta: {
                            title: '系统消费记录',
                        },
                        component: () => import('@/views/financial/consumptionRecords/index'),
                    },
                ],
            },
            {
                path: '/report',
                component: Layout,
                name: 'Report',
                meta: {
                    title: '报表管理',
                },
                children: [
                    {
                        path: 'timeShareRegister',
                        name: 'TimeShareRegister',
                        meta: {
                            title: '分时段注册报表',
                        },
                        component: () => import('@/views/report/timeShareRegister/index'),
                    },
                    {
                        // 分时段申请报表
                        path: 'timeShareApply',
                        name: 'TimeShareApply',
                        meta: {
                            title: '分时段申请报表',
                        },
                        component: () => import('@/views/report/timeShareApply/index'),
                    },
                    {
                        // 业绩报表
                        path: 'achievementReport',
                        name: 'AchievementReport',
                        meta: {
                            title: '业绩报表',
                        },
                        component: () => import('@/views/report/achievementReport/index'),
                    },
                ],
            },
        ],
    },

]
export const constantRoutes = [
    {
        path: '/login',
        name: 'login',
        component: () => import('@/components/Login/index'),
    },
    ...asyncRoutes
]
const routerHistory = createWebHashHistory()
const router = createRouter({
    scrollBehavior() {
        // 始终滚动到顶部
        return {top: 0}
    },
    history: routerHistory,
    routes: constantRoutes
})
export default router
